The complexity of updating an item is dominated by the time required to locate the target node.

  • Since updating an item necessitates first finding the item, the complexity is dominated by the linear search required to locate the target node.
  • We must traverse the list using pointer $p$ until the node containing value $x$ is found.
  • This search phase dictates the overall worst-case time complexity: $O(n)$.
  • Once the target node is located, modifying its value to $y$ is an instantaneous $O(1)$ operation.
  • The update involves only a direct memory write to the node's item field, requiring no pointer relinking or element shifting.

Complexity Analysis: Update an Item

Operation Time Complexity Reason
Locate Target Node $O(n)$ Requires linear traversal from $head$.
Modify Value Field $O(1)$ Direct memory write once pointer $p$ is positioned.
Overall Update (by value) $O(n)$ Dominated by the search phase.

Space complexity remains $O(1)$ as only a single traversal pointer is used.